#ifndef _HTTP_HTTP_H_
#define _HTTP_HTTP_H_


typedef enum
{
	HTTP_IMPL_START = 0,

	HTTP_IMPL_CONNECTING,
	HTTP_IMPL_CONNECT_FAIL,
	HTTP_IMPL_CONNECTED,

	HTTP_IMPL_LOCATION,
	HTTP_IMPL_LOCATION_FAIL,
	HTTP_IMPL_LOCATIONED,

	HTTP_IMPL_SEND_HEAD,
	HTTP_IMPL_SEND_HEAD_FAIL,
	HTTP_IMPL_SEND_HEADED,

	HTTP_IMPL_SEND_BODY,
	HTTP_IMPL_SEND_BODY_FAIL,
	HTTP_IMPL_SEND_BODYED,

	HTTP_IMPL_RECV_HEAD,
	HTTP_IMPL_RECV_HEAD_FAIL,
	HTTP_IMPL_RECV_HEADED,

	HTTP_IMPL_RECV_BODY,
	HTTP_IMPL_RECV_BODY_FAIL,
	HTTP_IMPL_RECV_BODYED,

	HTTP_IMPL_END,

	HTTP_IMPL_UNKNOWN

}http_state_t;

typedef enum {



}http_s_state_t;


typedef enum
{
	HTTP_METHOD_UNKNOWN,   
	HTTP_METHOD_GET,        
	HTTP_METHOD_POST,       
	HTTP_METHOD_PUT,        
	HTTP_METHOD_CONNECT,   
	HTTP_METHOD_PURGE,     
	HTTP_METHOD_DELETE,     
	HTTP_METHOD_HEAD,     
	HTTP_METHOD_OPTION,    
	HTTP_METHOD_PROPFIND,	
	HTTP_METHOD_OTHER,	
}http_method_t;


typedef enum
{
	// Content-Type: application/x-www-form-urlencoded
	HTTP_REQUEST_NORMAL,

	// Content-Type: multipart/form-data; boundary=xxx
	HTTP_REQUEST_MULTIPART_FORM,

	// Content-Type: application/octet-stream
	HTTP_REQUEST_OCTET_STREAM,

	// Content-Type: text/xml
	HTTP_REQUEST_TEXT_XML,

	// Content-Type: text/json
	HTTP_REQUEST_TEXT_JSON,

	//
	HTTP_REQUEST_OTHER
} http_request_t;

typedef enum
{
	HTTP_MIME_PARAM,        // http mime param
	HTTP_MIME_FILE          // http mime file 
}http_mime_t;

typedef const char*		http_addr_s;
typedef const char*		http_header;
typedef const char*		http_header_data;
typedef const char*		http_method_name;

#define http_host_len	256



interface IHttpNotify
{
	virtual ULONG Event(ULONG ulevent)											= 0;
	virtual ULONG SendHead(void* data, ULONG nSize, size_t nLen)				= 0;
	virtual ULONG SendBody(void* data, ULONG nSize, size_t nLen)				= 0;
	virtual ULONG RecvHead(void* data, ULONG nSize, size_t nLen)				= 0;
	virtual ULONG RecvBody(void* data, ULONG nSize, size_t nLen)				= 0;
};
interface IHttp_t : public IBase
{
	std_method(SetCookies)(http_header_data *data)								= 0;
	std_method(SetNotify)(IHttpNotify *Notify)									= 0;
	std_method(Perform)(ip_addr_s url, http_addr_s scheme, ip_port uport)		= 0;
	std_method(ReSet)()															= 0;
	std_method(Cancel)()														= 0;
	std_method_(int, IsComplete)()												= 0;
};
_DEFINE_IID(IHttp_t, "{B8D1828A-F5CF-4358-9848-6F59AD5C0B49}");


interface IHttp_s : public IBase
{
	
};
_DEFINE_IID(IHttp_s, "{47DF9098-26A7-4C75-91A7-68D320594807}");


interface IHttp : public IBase
{
	std_method(CreateHttp_t)(IBase **pBase)			= 0;
	std_method(CreateHttp_s)(IBase **pBase)			= 0;
};
_DEFINE_IID(IHttp, "{B39B6827-EE35-4900-AF0F-4E50C556A681}");

// {ED660EF7-7D0B-4CBE-8D92-D5F225434464}
_DEFINE_GUID(CLSID_IHttp,
    0xed660ef7, 0x7d0b, 0x4cbe, 0x8d, 0x92, 0xd5, 0xf2, 0x25, 0x43, 0x44, 0x64);
#endif